import Vue from "vue";
import Vuex from "vuex";
import app from "./modules/app";
import errorLog from "./modules/errorLog";
import getters from "./getters";

Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    userInfo: {
      userName: "",
      baseInfo: [],
      userAuthority: false,
      roleAuthority: false,
      organAuthority: false,
      loginAuthority: false,
      oprationAuthority: false,
      interfaceAuthority: false,
      administrator: false,
    },
    userThemes: "DEFAULT",
    pageSize: 20
  },
  mutations: {
    setUserInfo(state, obj) {
      if(obj.userName) {
        state.userInfo.userName = obj.userName;
      }
      if(obj.baseInfo) {
        state.userInfo.baseInfo = obj.baseInfo;
      }
      if(obj.userAuthority) {
        state.userInfo.userAuthority = obj.userAuthority;
      }
      if(obj.roleAuthority) {
        state.userInfo.roleAuthority = obj.roleAuthority;
      }
      if(obj.organAuthority) {
        state.userInfo.organAuthority = obj.organAuthority;
      }
      if(obj.loginAuthority) {
        state.userInfo.loginAuthority = obj.loginAuthority;
      }
      if(obj.oprationAuthority) {
        state.userInfo.oprationAuthority = obj.oprationAuthority;
      }
      if(obj.interfaceAuthority) {
        state.userInfo.interfaceAuthority = obj.interfaceAuthority;
      }
      if(obj.administrator) {
        state.userInfo.administrator = obj.administrator;
      }
      
    },
    //主题颜色
    setThemes(state, obj) {
      state.userThemes = "";
      state.userThemes = obj;
    }
  },
  modules: {
    app,
    errorLog
  },
  getters
});

export default store;
